<!DOCTYPE html>
<html>

<head>
    <link rel="stylesheet" href="../../plugins/layui/css/layui.css"/>
    <link rel="stylesheet" href="../../css/normalize.css"/>
    <link rel="stylesheet" href="../../css/fa.css"/>
    <link rel="stylesheet" href="../../css/icon.css"/>
    <link rel="stylesheet" href="../../css/ares_animate.min.css"/>
    <link rel="stylesheet" href="../../css/ares_hover_variant.min.css"/>
    <link rel="stylesheet" href="../../css/ares_reboot.css"/>
    <link rel="stylesheet" href="../../css/app.min.css"/>
    <link rel="stylesheet" href="../../css/iframe.css"/>
    <style>

    </style>
</head>

<body>
<table class="layui-hide" id="table" lay-filter="table"></table>
<div id="pagination"></div>


<script type="text/html" id="tableBar">
    <button class="layui-btn layui-btn-xs" lay-event="detail">详情</button>
</script>
<script type="text/javascript" src="../../plugins/layui/layui.js"></script>
<script type="text/javascript" src="../../aresExtends/config/layuiConfig.js"></script>
<script>
	layui.use(['table', 'laypage', 'conf', 'utils', 'dateFilters', 'mandyServices'], function (table, laypage, config, utils, dateFilters, mandyServices) {
		getPageList(1, config.pagination.limit);

		function getPageList(currentPage, pageSize) {
			mandyServices.mandy_get_my_task(null, currentPage, pageSize, 1, 1).then(function (res) {
				var data = res.data;
				laypage.render($.extend(config.pagination, {
					count: data.count,
					curr: data.current_page,
					jump: function (obj, first) {
						if (!first) getPageList(obj.curr, obj.limit);
					}
				}));
				table.render({
					elem: '#table',
					data: data.list,
					cellMinWidth: 80,
					cols: [[
						{title: '任务', templet: '<span>{{d.gauge.name}}</span>'},
						{
							title: '患者编号', field: 'number', width: 160,
							templet: '<span>{{d.prescription_item.prescription.medical_record.number}}</span>'
						},
						{title: '患者姓名', templet: '<span>{{d.patient.name}}</span>'},
						{
							title: '发布人',
							templet: '<span>{{d.prescription_item.prescription.creator.name}}</span>'
						},
						{
							title: '发布时间', width: 150,
							templet: function (d) {
								return dateFilters.dateTimeFormat(d.create_time);
							}
						},
						{
							title: '完成时间', width: 150,
							templet: function (d) {
								return dateFilters.dateTimeFormat(d.finish_time);
							}
						},
						{title: '操作', fixed: 'right', width: 60, templet: '#tableBar'}
					]]
				});
				table.on('tool(table)', function (obj) {
					switch (obj.event) {
						case 'detail':
							detail(obj.data);
							break;
					}
					;
				});
			})
		}

		function detail(data) {
			var query = {
				prcpItemId: data.prescription_item.id
			};
			utils.pushTopRoute('/evaluation/gauge', query)
		}

	})
</script>


</body>

</html>
